package Demo_zhuanshu.XueQiang03;



interface Compute{
    public int computer( int n,int m);
}
class add implements Compute{
     public int computer(int n,int m){
        return n+m;
    }
}
class sub implements Compute{
    public int computer(int n,int m){
        return n-m;
    }
}
class mul implements Compute{
    public int computer(int n,int m){
        return n*m;
    }
}
class div implements Compute{
    public int computer(int n,int m){
        if(m == 0){
            return -1;
        }
        else {
            return n/m;
        }
    }
}
class UseCompute{
    public void useCom(Compute com,int one,int two){
       System.out.println(com.computer(one, two));

    }
}
class Test{
    public static void main(String[] args) {
        UseCompute  a = new UseCompute();
        add s1 = new add();
        sub s2 = new sub();
        mul s3 = new mul();
        div s4  = new div(); 
        System.out.print("和：");a.useCom(s1, 3, 6);
        System.out.print("差：");a.useCom(s2, 3, 6);
        System.out.print("积：");a.useCom(s3, 3, 6);
        System.out.print("商：");a.useCom(s4, 3, 6);
        System.out.print("商：");a.useCom(s4, 3, 1);
    }
}
